package exam;

import java.io.FileReader;
import java.util.*;

public class Test {
    public static void main(String[] args)throws Exception {
        Properties prop = new Properties();
        HashMap<String, String> map = new HashMap<>();

        prop.load(new FileReader("People.txt"));

        Set<String> keys = prop.stringPropertyNames();
        for (Iterator<String> it = keys.iterator(); it.hasNext();) {
            String key = it.next();

            String value = prop.getProperty(key);
           map.put(key,value);
        }
        Set<String> keys1= map.keySet();
        int age =0;
        for (Iterator<String> it1 = keys1.iterator(); it1.hasNext();) {
          String key =it1.next();
          String value1 =map.get(key);
          age =Integer.parseInt(value1);
          if(age>30){
             age =30;
             String age1 =age+"";
             map.put(key,age1);
          }
        }
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> keyValue : entries) {

            String key3 = keyValue.getKey();
            String value3 = keyValue.getValue();
            //输出key和value
            System.out.println(key3+"="+value3);
        }


    }
}
